Skip to content

improvement(tests): db-mock migration tranche 3 — lib/workflows, lib/copilot remainder, ee/core/misc#5864

Merged
waleedlatif1 merged 2 commits into
stagingfrom
test/db-mock-migration-3
Jul 22, 2026
Merged

improvement(tests): db-mock migration tranche 3 — lib/workflows, lib/copilot remainder, ee/core/misc#5864
waleedlatif1 merged 2 commits into
stagingfrom
test/db-mock-migration-3

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

Type of Change

  • Improvement

Testing

Full apps/sim suite green locally (13704/13705; sole failure is the known local ripgrep dependency, green in CI). Every file verified standalone, per-cluster, and with neighbor sweeps (lib/workflows 985 tests, lib/copilot 900, ee/workspaces/admin/core 749). tsc + biome clean.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 22, 2026 10:21pm

Request Review

@cursor

cursor Bot commented Jul 22, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Test-only refactor with no application code changes; risk is limited to test fidelity if a migrated mock no longer matches real query ordering.

Overview
Tranche 3 of the shared database test mock rollout: 27 test suites in apps/sim stop defining their own Drizzle-style vi.mock('@sim/db', …) chains and instead use @sim/testing (dbChainMock, dbChainMockFns, queueTableRows, resetDbChainMock, and often schemaMock).

Coverage spans EE (permission checks, workspace forking cleanup/unlink), lib/workflows (deploy, lifecycle, duplicate, schedules, deployment outbox, execution state, skills), lib/copilot (chat, stream liveness, agent URL, knowledge/tools), plus auth/ban, admin, BYOK, outbox, idempotency cleanup, organizations, uploads, and workspace admin-move. Tests now queue rows by schema table and assert via dbChainMockFns (e.g. set, insert, transaction) instead of hand-rolled mockLimit / mockWhere / custom createMockTx helpers.

workspace-context.test.ts drops a no-op @sim/db mock entirely. afterAll(resetDbChainMock) and beforeEach(resetDbChainMock) are added consistently so queued rows and spy state do not leak across tests.

No production/runtime behavior changes—only test setup and assertions.

Reviewed by Cursor Bugbot for commit 1000474. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR moves 27 test suites onto the shared database mock utilities. The main changes are:

  • Replaces suite-local @sim/db factories with dbChainMock.
  • Queues select results by schema table with queueTableRows.
  • Standardizes mock reset, transaction, mutation, and operator assertions.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • The queued rows follow the current production query order.
  • Reset and mutation behavior remain consistent with the prior test factories.

Important Files Changed

Filename Overview
apps/sim/ee/access-control/utils/permission-check.test.ts Queues workspace and default permission-group results in production query order.
apps/sim/ee/workspace-forking/lib/copy/cleanup-failed.test.ts Moves table reads, mutation tracking, and update-failure injection to the shared mock.
apps/sim/ee/workspace-forking/lib/lineage/unlink.test.ts Uses the shared transaction executor and mutation spies for unlink behavior.
apps/sim/lib/admin/external-collaborators.test.ts Queues member and permission rows under their respective base tables.
apps/sim/lib/core/idempotency/cleanup.test.ts Uses the shared Drizzle operator mocks for namespace filter assertions.

Reviews (1): Last reviewed commit: "improvement(tests): use the shared notLi..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant